package IC.AST;

public class UnaryOperationExpression extends Expression
{
	private Operation _operation;
	private Expression _expression;
	
	public Object Visit(Visitor visitor) { return visitor.Visit(this); }
	
	public UnaryOperationExpression(Interval interval, Operation operation, Expression expression)
	{
		super(interval);
		_operation = operation;
		_expression = expression;
		GiveBirth(_expression);
	}
	
	public Operation GetOperation() { return _operation; }
	public Expression GetExpression() { return _expression; }
	
	public enum OperationType
	{
		Integer (0, "integer"), 
		Boolean (1, "boolean");
		
		private int _index;
		private String _string;
		
		private OperationType(int index, String string)
		{
			_index = index;
			_string = string;
		}
		
		public String toString() { return _string; }
		public boolean equals (OperationType other) { return _index == other._index; }
		
	}
	
	public enum Operation
	{
		Minus ("-", OperationType.Integer, 0),
		Not ("!", OperationType.Boolean, 1);

		
		private String _string;
		private OperationType _type;
		private int _id;
		
		private Operation (String string, OperationType type, int id)
		{
			_string = string;
			 _type = type;
			_id = id;
		}
		
		public boolean equals(Operation op) { return _id == op._id; }
		public String toString() { return new String(_string); }
		public OperationType GetType() { return _type; }
	}
}
